# Maintainer: nalla <nalla@hamal.uberspace.de>

pkgname=('git-extra')
_ver_base=1.1
pkgver=1.1.460.b585ebe
pkgrel=1
pkgdesc="Git for Windows extra files"
arch=('i686' 'x86_64')
url="https://github.com/git-for-windows/build-extra"
license=('GPL')
groups=('VCS')
depends=('git-for-windows-keyring' 'diffutils')
optdepends=('vim' 'filesystem')
install='git-extra.install'
pkgver() {
  cd "$startdir"
  test ! -f "$(git rev-parse --git-path shallow)" || git -c http.sslbackend fetch --unshallow
  rev="$(git rev-list -1 HEAD -- .)"
  test -n "$(git show . |
    sed -n -e '1,/^@@/d' -e '/^[-+]pkgver=/d' -e '/^[-+]/p')" ||
  rev="$(git rev-list -1 $rev^ -- .)"
  printf "%s.%s.%s" "${_ver_base}" "$(git rev-list --count $rev -- .)" \
    "$(git rev-parse --short $rev)"
}
source=('inputrc'
        'vimrc'
        'vi'
        'git.nanorc'
        'notepad'
        'wordpad'
        'create-shortcut.c'
        'Makefile'
        'SystemInfo.cpp'
        'SystemInfo.h'
        'WhoUses.cpp'
        'git-prompt.sh'
        'aliases.sh'
        'env.sh'
        'bash_profile.sh'
        'msys2-32.ico'
        '99-post-install-cleanup.post'
        'gitattributes'
        'astextplain'
        'git-sdk.sh'
        'sdk.completion'
        'git-update-git-for-windows'
        'git-update'
        'blocked-file-util.c'
        'zzz_rm_stackdumps.sh'
        'proxy-lookup.c'
        'git-askyesno.c'
        'update-via-pacman.bat'
        'git-credential-helper-selector.c'
        'git-credential-helper-selector.manifest'
        'git-credential-helper-selector.rc')
sha256sums=('9efaf8dccc08c7cddc58cb589bab5aac5c0894661175a344ca02b2aa849382bd'
            'c26d22aaa1d3dc615d474e0d60c5c0f19598d61d9205e19ec87aac1b28bb07c1'
            '640d04d2a2da709419188a986d5e5550ad30df23c7ea9be1a389c37a6b917994'
            '17c90698d4dd52dd9f383e72aee54ecea0f62520baf56722de5c83285507c0d9'
            '3cd83627f1d20e1108533419fcf33c657cbcf777c3dc39fa7f13748b7d63858a'
            'a9ada325a279ce460aeb663a715e4c335d8972f497d48d97ff5524053b1fb43a'
            'ad295ceb2c66aaf5fec85705110f701924eb6733b68663aaa52a90b950f03caa'
            '573ab22be9381feade4a4cdeb5e3d0761224e2e85e017be418c7004fb85fa8b5'
            'd212e1bbe75a9f81443126701324c9c44c3ed5750dd9822eba754a1799ed13b3'
            '402c51eba82453a76f5110f4754bb1005df507a6e4532574c2b9627ff4e1dc81'
            'd9024bab283ebb67b5d39d49ee5d2592e170abf1f92d3db34edcdd7eeed0b6b9'
            '0a4d04eb5ce035f9b94ebad51f0fc366ffda1f384fa6e586e8eef140440fb012'
            '4678d4939642b9a5b13e2f700a6968550f8e936738879a625479df5429a60e53'
            '255c64eecf1dbd188ef3452e73b9e099f3bb0e56bc23ff1493e4cc57f724d52f'
            '02d38e480a1ec4227e94a5aa073945901680aa3387e3386f8b77f10426ebbc75'
            'dcbd1b981d5b899afe30151a5f5a27ea52025ff1335f131af1b5891f62ddd55b'
            '683ab066be19cb4defec470ebd53f165ca5dbf761fd40c13aee8abe31ba42803'
            '1cf2c13fb97c51375a76ed479362c3cbcdb51ab4d3a745e8d2c3a780badd8d46'
            '37e3412480f0fc5b742406d569baa1a6c572f5be16650ae70c65169c5fd4a8e3'
            '7615a693a23f8b75737bf27012b656ec0fdc2f4fe25736fc76e95d82ae3c7d45'
            '22f41610dea842890955032af30efdb60e80f310e95a04e57ab36b10e0376923'
            '5f0c7c95e03dde7a9b2f2b33acdb3964dc852fd8112a7151078d4038a0a42512'
            '15b40ab72dea884f659cfbe441e9a40b2d8d63e490a3c14824a55607368e476d'
            'ebd1d20aa94be11c6b9bec7d33614d32016343d282c4716d0561ab41407c99bf'
            '97e89689d91747ddb5ee873ae864aebcbb8d0364a52fa198db1e439ee2965b9b'
            '2199a518823de64a581854b9173f5f06cab191cfde50f04f3628200127690a4f'
            '0e3af7dacb665306076590ce9aec935929c198cec1bf9c5e161dfe285502ba67'
            'c4cb705fcf117157e2648751212aac29f2f256ee54caa9b6eec5aef0474aec29'
            'e9de6e6e92a147c53dd51dcaacef57832d45227bf0b3d50274a2d15fec3b7227'
            '247dc84535c89d2e00c6a741d4317cd76ae5958c91ac867e2e74d4e73bc3c998'
            '78307cd6c04a16240f68197e9155697bc75d5df8e4c8514ff67712bb93a1cd4a')

prepare() {
  test $startdir/$pkgname.install -nt $startdir/$pkgname.install.in &&
  test $startdir/$pkgname.install -nt $startdir/gitconfig &&
  test $startdir/$pkgname.install -nt $startdir/gitattributes ||
  sed -e "/^@@GITCONFIG@@$/r $startdir/gitconfig" \
        -e "/^@@GITCONFIG@@$/d" \
        -e "/^@@GITATTRIBUTES@@$/r $startdir/gitattributes" \
        -e "/^@@GITATTRIBUTES@@$/d" \
        <$startdir/$pkgname.install.in >$startdir/$pkgname.install
}

build() {
  export CC=${MINGW_CHOST}-gcc
  export CXX=${MINGW_CHOST}-g++
  export SRCDIR=$srcdir
  export BUILDDIR=build-${MINGW_CHOST}
  mkdir -p ${BUILDDIR}
  make -f Makefile
}

package() {
  builddir=build-${MINGW_CHOST}
  install -d -m755 $pkgdir/etc/profile.d
  install -d -m755 $pkgdir/usr/share/bash-completion/completions
  install -d -m755 $pkgdir/etc/post-install
  install -d -m755 $pkgdir/usr/bin
  install -d -m755 $pkgdir/usr/share/git
  install -d -m755 $pkgdir/usr/share/nano
  install -d -m755 $pkgdir${MINGW_PREFIX}/bin
  install -d -m755 $pkgdir${MINGW_PREFIX}/libexec/git-core
  install -d -m755 $pkgdir/usr/share/makepkg/lint_package
  install -m644 inputrc $pkgdir/etc
  install -m644 vimrc $pkgdir/etc
  install -m644 git.nanorc $pkgdir/usr/share/nano
  install -m755 vi $pkgdir/usr/bin
  install -m755 notepad $pkgdir/usr/bin
  install -m755 wordpad $pkgdir/usr/bin
  install -m755 $builddir/create-shortcut.exe $pkgdir${MINGW_PREFIX}/bin
  install -m755 $builddir/WhoUses.exe $pkgdir${MINGW_PREFIX}/bin
  install -m755 $builddir/blocked-file-util.exe $pkgdir${MINGW_PREFIX}/bin
  install -m755 $builddir/proxy-lookup.exe $pkgdir${MINGW_PREFIX}/bin
  install -m755 $builddir/git-askyesno.exe $pkgdir${MINGW_PREFIX}/bin
  install -m755 $builddir/git-credential-helper-selector.exe $pkgdir${MINGW_PREFIX}/bin
  install -m755 git-prompt.sh $pkgdir/etc/profile.d
  install -m755 aliases.sh $pkgdir/etc/profile.d
  install -m755 env.sh $pkgdir/etc/profile.d
  install -m755 bash_profile.sh $pkgdir/etc/profile.d
  install -m755 git-sdk.sh $pkgdir/etc/profile.d
  install -m755 sdk.completion $pkgdir/usr/share/bash-completion/completions/sdk
  install -m644 msys2-32.ico $pkgdir/usr/share/git
  install -m644 99-post-install-cleanup.post $pkgdir/etc/post-install
  install -m755 astextplain $pkgdir/usr/bin
  install -m755 git-update-git-for-windows $pkgdir${MINGW_PREFIX}/libexec/git-core
  install -m755 git-update $pkgdir${MINGW_PREFIX}/libexec/git-core
  install -m755 update-via-pacman.bat $pkgdir
  install -m755 zzz_rm_stackdumps.sh $pkgdir/usr/share/makepkg/lint_package
}
